/* 
    对 renameTest 文件夹下的文件进行补零排序操作
*/
const fs = require("fs");
const path = require("path");

const renameDirPath = path.join(__dirname, "./renameTest");

let files = fs.readdirSync(renameDirPath);
console.log(files, "renameDir");

files.forEach((file) => {
  let [num, suffixe] = file.split(".");
  let newName = `0${Number(num)}.${suffixe}`;
  console.log(newName, "newName");
  fs.rename(
    `${renameDirPath}/${file}`,
    `${renameDirPath}/${newName}`,
    (err) => {
      if (err) throw err;
      console.log("重命名成功!");
    }
  );
});
